﻿<Window x:Class="Poet.Views.GoToLineView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:Converters="clr-namespace:Poet.Converters"
        Icon="/Avalon;component/../Icons/Rose_32x32.png"
        WindowStartupLocation="CenterOwner"
        Title="{Localizing GoToLine}"
        Height="130" Width="300"
        ResizeMode="NoResize">
    
    <Window.Resources>

        <Converters:GoToLineRangeToStringConverter x:Key="GoToLineRangeToStringConverter"/>
        
        <ControlTemplate x:Key="TextBoxErrorTemplate">
            <AdornedElementPlaceholder>
                <Ellipse ToolTip="{Localizing ValueMustBeAnIntegerInTheAllowedRange}" 
                         Margin="5,0,5,0" Width="10" Height="10" HorizontalAlignment="Right">
                    <Ellipse.Fill>
                        <LinearGradientBrush>
                            <GradientStop Color="#11FF1111" Offset="0"/>
                            <GradientStop Color="#FFFF0000" Offset="1"/>
                        </LinearGradientBrush>
                    </Ellipse.Fill>
                </Ellipse>
            </AdornedElementPlaceholder>
        </ControlTemplate>

        <Style TargetType="TextBox">
            <Style.Triggers>
                <Trigger Property="Validation.HasError" Value="True">
                    <Setter Property="Validation.ErrorTemplate" Value="{StaticResource TextBoxErrorTemplate}"/>
                    <Setter Property="ToolTip">
                        <Setter.Value>
                            <Binding Path="(Validation.Errors)[0].ErrorContent"  RelativeSource="{x:Static RelativeSource.Self}"/>
                        </Setter.Value>
                    </Setter>
                </Trigger>
            </Style.Triggers>
        </Style>

    </Window.Resources>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Label Grid.Row="0" Margin="12,0">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Localizing LineNumber}"/>
                <TextBlock Text=" "/>
                <TextBlock Text="{Binding Converter={StaticResource GoToLineRangeToStringConverter}}"/>
                <TextBlock Text=":"/>
            </StackPanel>
        </Label>

        <TextBox TabIndex="0" Grid.Row="1" Margin="12,0" Name="LineNumberTextBox" TextChanged="LineNumberTextBox_OnTextChanged" Text="{Binding LineNumber,   ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"/>
        <Button TabIndex="1" Content="{Localizing Ok}" Name="OkButton" IsDefault="True" Grid.Row="3" Height="23" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="75" Margin="0,12,93,12" Click="Button_Click"/>
        <Button TabIndex="2" Content="{Localizing Cancel}" IsCancel="True" Grid.Row="3" Height="23" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="75" Margin="0,12,12,12"/>
    </Grid>
</Window>
